#include <mysql/mysql.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>

class MysqlConnect {
	MYSQL *conn;
	MYSQL_RES *res;
	MYSQL_ROW row;

	const char *server = "localhost";
	const char *user = "root"; // 替换为你的用户名
	const char *password = "666888"; // 替换为你的密码
	const char *database = "smart_farm"; // 替换为你的数据库名


public:
    MysqlConnect(void);
    ~MysqlConnect();
    int ConnectInit();

	    // 插入传感器数据
    int insertSensorData(int farm_id, double co2, double temperature, double humidity, double light, const std::string& time);
	MYSQL_RES *result();
	unsigned int resultCount();
	int exec(std::string query);
    
	bool farmIsExist(int farm_id);
};
